package game;
import java.util.ArrayList;

import fields.*;

public class Player extends Account {

		// Ting, som programmet skal huske om spilleren.
		private String name;
		private int field, choice;
		private boolean lost, active;
		public boolean inJail;
		
		private ArrayList<Fleet> fleets;
		private ArrayList<LaborCamp> laborcamps;
		private ArrayList<Territory> territories;
		
		//Konstruktoer er den der laver et objekt fx. en spiller.
		public Player() {
			name="";
			choice=2;
			field=1;
			lost=false;			//S√¶ttes til true, hvis spillerens konto g√•r i 0.
			active=true;		//S√¶ttes til false, hvis spilleren taber.
			inJail=false;
			fleets = new ArrayList<Fleet>();
			laborcamps = new ArrayList<LaborCamp>();
			territories = new ArrayList<Territory>();
		}
		
		public void setName(String name) {
			this.name=name;
		}
		
		public boolean compareName(String navn1) {
			boolean b=false;
			if (name.compareToIgnoreCase(navn1)==0) {
				b=true;
			}
			return b;
		}
		
		public void move(int move)
		{
			field += move;
			if (field>40) field=field%40;
			if (field==0) field=1;
		}
		
		public int getField()
		{
			return field;
		}
		
		public String getName() {
			return name;
		}	
		
		public boolean hasLost()
		{
			if (beholdning==0) lost=true;
			return lost;
		}
		
		public boolean isActive()
		{
			return active;
		}
		
		public void bankrupt()
		{
			active=false;
			for (int i=0; i<fleets.size(); i++)
			{
				fleets.get(i).forSale();
			}
			for (int i=0; i<laborcamps.size(); i++)
			{
				laborcamps.get(i).forSale();
			}
			for (int i=0; i<territories.size(); i++)
			{
				territories.get(i).forSale();
			}
		}
		
		public void addFleet(Fleet f)
		{
			fleets.add(f);
		}
		
		public int getFleets()
		{
			return fleets.size();
		}
		
		public void addLaborCamp(LaborCamp l)
		{
			laborcamps.add(l);
		}
		
		public int getLaborCamps()
		{
			return laborcamps.size();
		}
		
		public void addTerritory(Territory t)
		{
			territories.add(t);
		}
		
		public void setChoice(int a)
		{
			choice=a;
		}
		
		public int getChoice()
		{
			return choice;
		}
		
		public int getAccount()
		{
			return beholdning; //Test
		}
		
		public void setActive(boolean status)
		{
			active = status;
		}

	}